﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Coslen.Framework.Helpers
{
    public static class SecurityHelpers
    {
        /// <summary>        
        /// Procuses an MD5 hash string of the password        
        /// </summary>        
        /// <param name="password">password to hash</param>        
        /// <returns>MD5 Hash string</returns>        
        public static string EncryptPassword(string password, string butterfly)
        {
            //we use codepage 1252 because that is what sql server uses            
            byte[] pwdBytes = Encoding.GetEncoding(1252).GetBytes(butterfly + password);
            byte[] hashBytes = System.Security.Cryptography.MD5.Create().ComputeHash(pwdBytes);
            return Encoding.GetEncoding(1252).GetString(hashBytes);
        }

    }
}
